package com.job.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name="forder")
public class Forder implements Serializable {
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer id;// 管理员编号，自动增长
	@Column(length = 200)
	private String address;// 收件人邮编
	@Column(columnDefinition="timestamp default CURRENT_TIMESTAMP")
	@Temporal(TemporalType.TIMESTAMP)
	private Date date = new Date();// 下单日期
	@Column(length = 20)
	private String name;// 收件人名字
	@Column(length = 20)
	private String phone;// 收件人电话
	@Column(length = 20)
	private String post;// 配送信息
	@Column(length = 20)
	private String remark;// 配送信息
	@Column(precision = 8, scale = 2)
	private BigDecimal total;// 订单总金额
	@ManyToOne
	@JoinColumn(name = "sid",columnDefinition="INT default 1")
	private Status status;
	@ManyToOne
	@JoinColumn(name = "uid")
	private User user;

	@OneToMany(mappedBy="forder")
	private Set<Sorder> sorders=new HashSet<Sorder>();
	
	public Forder() {
		super();
	}
	public String getAddress() {
		return address;
	}

	public Date getDate() {
		return date;
	}

	

	public Integer getId() {
		return id;
	}



	public String getName() {
		return name;
	}



	public String getPhone() {
		return phone;
	}



	public String getPost() {
		return post;
	}

	

	public String getRemark() {
		return remark;
	}

	public Status getStatus() {
		return status;
	}

	public BigDecimal getTotal() {
		return total;
	}

	public User getUser() {
		return user;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public void setPost(String post) {
		this.post = post;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public void setTotal(BigDecimal total) {
		this.total = total;
	}

	public void setUser(User user) {
		this.user = user;
	}
	public Set<Sorder> getSorders() {
		return sorders;
	}
	public void setSorders(Set<Sorder> sorders) {
		this.sorders = sorders;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Forder other = (Forder) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	
}
